#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;

void output(vector<int>& arr) {
	int n = arr.size(), len = 0;
	for (int i = 0; i < n; i++) len += printf("%3d", i);
	cout << "\n";
	
	for (int i = 0; i < len; i++)printf("-");
	cout << "\n";
	
	for (int i = 0; i < n; i++) len += printf("%3d", arr[i]);
	cout << "\n";
}

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> arr;
	deque<int> q;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		arr.push_back(a);
	}
	output(arr);
	for (int i = 0; i < n; i++) {
		while (!q.empty() && arr[q.back()] > arr[i])q.pop_back();
		q.push_back(i); //压入下标
		if (i - q.front() == k) q.pop_front(); //弹出队头
		printf("[%d, %d] = arr[%d] = %d \n",
			max(i - k + 1, 0), i,
			q.front(),arr[q.front()]);
	}
}

//测试数据
//10 4
//7 8 5 6 2 3 4 1 10 9